<template>
  <div>
    <van-popup v-model="show" position="bottom" @close="closeDrawerHandler">
      <div class="CustomPopupBottom-top">
        <span>{{ title }}</span>
        <i class="iconfont" @click="closeDrawerHandler" v-html="'&#xe647;'" />
      </div>
      <slot name="container" />
    </van-popup>
  </div>
</template>
<script>
export default {
  id: 'CustomPopupBottom',
  props: {
    /**
     * 抽屉状态
     */
    showDrawer: {
      type: Boolean,
      default: false
    },
    /**
     * 抽屉标题
     */
    title: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      show: false // 抽屉状态防止直接修改props
    }
  },
  watch: {
    showDrawer: {
      handler(newVal) {
        this.show = newVal
      },
      deep: true,
      immediate: true
    }
  },
  inject: ['layout'],
  created() {
  },
  methods: {
    closeDrawerHandler() {
      this.$emit('close', false)
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep .van-popup {
  border-radius: 12px 12px 0 0;
  overflow: hidden !important;
  .CustomPopupBottom {
    &-top {
      height: 50px;
      border-radius: 12px 12px 0 0;
      overflow: hidden;
      background-color: #e5e5e5;
      padding: 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      span {
        font-size: 17px;
        font-weight: 700;
      }
      i {
        font-size: 16px;
        font-weight: 700;
      }
    }
  }
}
</style>
